package com.qvtu.springboot.mapper;

import com.qvtu.springboot.entity.Employee;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface EmployeeMapper {
    List<Employee> selectAll(Employee employee);

//    通过注解形式查询数据   和xml文件内些查询语句是一样的效果
    @Select("select * from employee where id=#{id}")
    Employee selectById(Integer id);

//    注意这里是下划线还是驼峰
    @Insert("insert into `employee` (username,password,role,name,sex,no,age,description,department_id,avatar)" +
            "values (#{username},#{password},#{role},#{name},#{sex},#{no},#{age},#{description},#{departmentId},#{avatar})")
    void insert(Employee employee);

    @Delete("delete from `employee` where id=#{id}")
    void deleteById(Integer id);

    @Update("update `employee` set username=#{username},password=#{password}, name=#{name},sex=#{sex},no=#{no},age=#{age},description=#{description},department_id=#{departmentId},avatar=#{avatar} where id=#{id}")
    void update(Employee employee);

    @Select("select * from `employee` where username=#{username}")
    Employee selectByUsername(String username);

    @Select("select * from `employee` where no=#{no}")
    Employee selectByNo(String no);

}
